import { request } from "vendor/utils/T";
import { toApi } from "@/service/proxyApi";
import {RespDataType, RequestDataType} from "./apiType";

export * from "./apiType";
const {get, postJSON, del, put } = request;

/**
 * 获取菜单管理列表数据
 */
export const getMenuList = (params:{menuName?: string, status?: string})=>{
  return get<RespDataType.MenuItem[]>(toApi("system/menu/list"),params)
}

// /**
//  * 获取选择列表数据
//  */
// export const getMenuSelectList = ()=>{
//     return get<RespSysSettingDataType.TreeSelectData[]>(toApi("/system/menu/treeSelectData"))
// }

/**
 * 创建菜单
 */
export const createMenu = (params:RequestDataType.CreateMenuItem)=>{
    return postJSON(toApi("system/menu"),params);
}

/**
 * 更新菜单
 */
export const updateMenu = (menuId:number, params:RequestDataType.CreateMenuItem) => {
    params = {...params,menuId:menuId};
    return put(toApi("system/menu"), params);
}

/**
 * 删除菜单
 */
export const deleteMenu = (menuIdList: number[]) => {
    return del(toApi("system/menu"), menuIdList);
}

/**
 * 获取单个通知内容
 */
export const getMenu = (menuId: number) => {
    return get<RequestDataType.CreateMenuItem>(toApi("system/menu"), {menuId});
}